package cn.melon.window;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import cn.melon.mod.roll.RollInfo;
import cn.melon.view.control.SubmitRollModification;

/**
 * 修改学籍信息类
 * @author HZY
 *
 */
public class RollInfoModifyWindow extends JFrame {
    
    private String[] textStr = {"个性签名: ","姓名: ","性别: ","民族: ","学号: ","一卡通号: ","政治面貌: ","婚姻状况: ",
            "学号: ","籍贯: ","出生日期: ","家庭住址: ","校区: ","院系: ","专业: ","当前年级: ","学制: ","手机号码: ","电子邮箱: "};
    private JTextField rollUpdateDateChange = new JTextField("",20);
    private JTextField personalMottoChange = new JTextField("",20);
    private JTextField nameChange = new JTextField("",20);
    private JTextField sexChange = new JTextField("",20);
    private JTextField nationChange = new JTextField("",20);
    private JTextField studentNumberChange = new JTextField("",20);
    private JTextField cardNumChange = new JTextField("",20);
    private JTextField politicalStatusChange = new JTextField("",20);
    private JTextField martialStatusChange = new JTextField("",20);
    private JTextField idCardChange = new JTextField("",20);
    private JTextField nativePlaceChange = new JTextField("",20);
    private JTextField dateBirthChange = new JTextField("",20);
    private JTextField addressChange = new JTextField("",20);
    private JTextField curCampusChange = new JTextField("",20);
    private JTextField departmentChange = new JTextField("",20);
    private JTextField majorChange = new JTextField("",20);
    private JTextField curGradeChange = new JTextField("",20);
    private JTextField lengthChange = new JTextField("",20);
    private JTextField phoneChange = new JTextField("",20);
    private JTextField emailChange = new JTextField("",20);
    private JTextField[] jTextFields = {personalMottoChange,nameChange,sexChange,nationChange,studentNumberChange,cardNumChange,politicalStatusChange,
            martialStatusChange,idCardChange,nativePlaceChange,dateBirthChange,addressChange,curCampusChange,departmentChange,majorChange,curGradeChange,lengthChange,
            phoneChange,emailChange};
    
    /**
     * 构造函数
     * @param student 学生学籍信息
     * @param m 主窗口句柄, 实时修改主窗口
     */
    public RollInfoModifyWindow(RollInfo student, MainWindow m) {
        this.setResizable(false);
        this.setLocationRelativeTo(null);

        this.setSize(400,700);
        personalMottoChange.setText(student.getSign());
        nameChange.setText(student.getName());
        sexChange.setText(student.getSex());
        nationChange .setText(student.getNation());
        studentNumberChange.setText(student.getStudentNumber());
        cardNumChange.setText(student.getCardNum());
        politicalStatusChange.setText(student.getPoliticalStatus());
        martialStatusChange.setText(student.getMaritalStatus());
        idCardChange.setText(student.getIdCard());
        nativePlaceChange.setText(student.getNativePlace());
        dateBirthChange.setText(student.getDateBirth());
        addressChange.setText(student.getAddress());

        curCampusChange.setText(student.getCurCampus());
        departmentChange.setText(student.getDepartment());
        majorChange.setText(student.getMajor());
        curGradeChange.setText(student.getCurGrade());
        lengthChange.setText(student.getLength());
        phoneChange.setText(student.getPhone());
        emailChange.setText(student.getEmail());
        
        JButton submit = new JButton("提交");
        submit.addActionListener(new SubmitRollModification(this, m));
        JPanel content = new JPanel();
        
        GridBagLayout layout = new GridBagLayout();
        content.setLayout(layout);
        this.getContentPane().add(content);
        
        GridBagConstraints constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.EAST;
        constraints.fill = GridBagConstraints.NONE;
        constraints.weightx = 100;
        constraints.weighty = 100; 
        for(int i=0;i<textStr.length;i++){

            constraints.gridx = 0;
            constraints.gridy = i;
            content.add(new JLabel(textStr[i]),constraints);
            
            constraints.anchor = GridBagConstraints.CENTER;
            constraints.gridx = 1;
            content.add(jTextFields[i],constraints);
            
            constraints.anchor = GridBagConstraints.EAST;
            constraints.gridx = 2;
            content.add(Box.createRigidArea(new Dimension(2, 15)));
        }
        constraints.anchor = GridBagConstraints.CENTER;
        constraints.gridx = 1;
        constraints.gridy = textStr.length;
        content.add(submit, constraints);
    }

    public String getRollUpdateDateChange() {
        return rollUpdateDateChange.getText();
    }


    public String getPersonalMottoChange() {
        return personalMottoChange.getText();
    }


    public String getNameChange() {
        return nameChange.getText();
    }


    public String getSexChange() {
        return sexChange.getText();
    }


    public String getNationChange() {
        return nationChange.getText();
    }


    public String getStudentNumberChange() {
        return studentNumberChange.getText();
    }


    public String getCardNumChange() {
        return cardNumChange.getText();
    }


    public String getPoliticalStatusChange() {
        return politicalStatusChange.getText();
    }


    public String getMartialStatusChange() {
        return martialStatusChange.getText();
    }


    public String getIdCardChange() {
        return idCardChange.getText();
    }


    public String getNativePlaceChange() {
        return nativePlaceChange.getText();
    }


    public String getDateBirthChange() {
        return dateBirthChange.getText();
    }


    public String getAddressChange() {
        return addressChange.getText();
    }


    public String getCurCampusChange() {
        return curCampusChange.getText();
    }


    public String getDepartmentChange() {
        return departmentChange.getText();
    }


    public String getMajorChange() {
        return majorChange.getText();
    }


    public String getCurGradeChange() {
        return curGradeChange.getText();
    }


    public String getLengthChange() {
        return lengthChange.getText();
    }


    public String getPhoneChange() {
        return phoneChange.getText();
    }


    public String getEmailChange() {
        return emailChange.getText();
    }
}
